package org.star.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.star.service.CouponService9000;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author : 一叶浮萍归大海
 * @Date: 2024/6/11 16:51
 * @Description:
 */
@RefreshScope
@RestController
public class CouponController9000 {

    @Value("${nacos.config.user.name}")
    private String username;
    @Value("${nacos.config.user.age}")
    private Integer age;

    @Resource
    private CouponService9000 couponService;

    /**
     * 根据id查询优惠券
     * @param id
     * @return
     */
    @GetMapping("/getCouponById/{id}")
    public String getCouponById(@PathVariable("id") Integer id) {
        String result = couponService.getCouponById(id);

        return result;
    }

    @GetMapping("/getNacosConfig")
    public Map<String,Object> getNacosConfig() {
        Map<String,Object> resultMap = new HashMap<>(2);
        resultMap.put("username",username);
        resultMap.put("age",age);

        return resultMap;
    }
}
